<style>
  .form input, .form textarea, .form select {
    margin: auto;
    clear: both;
    width: auto;
    float: none;
  }
</style>

<div class="main-content grid_5 alpha">
  <header>
    <div class="action-buttons clearfix fr">
        <a href="#" class="has-popupballoon button button-gray"><span class="add"></span>Upload Catalog</a>
        <div class="popupballoon top">
						<form id="form" class="form" novalidate="true" action="<?php echo bu('admin/catalogs/create'); ?>" method="POST" enctype="multipart/form-data">
								<h3>Upload New Catalog</h3>
								<h4>Title *<h4>
								<input type="text" name="Catalogs[title]" required="required" style="width:150px;" />

								<br /><br /><br />
								<h4>File *</h4>
								<?php echo CHtml::activeFileField($model, 'upload', array('required' => 'required', 'style' => 'width:150px;')); ?>

								<button class="button button-orange" type="submit">Upload</button>
								<button class="button button-gray close" type="reset">Cancel</button>
						</form>
        </div>
    </div>
    <h2>Catalogs</h2>
  </header>

  <section>
    <?php echo $this->renderPartial('/partials/_notifications'); ?>


		<table class="datatable paginate sortable full">
			<thead>
				<tr>
					<th>Title</th>
					<th>Category</th>
					<th>Created At</th>
					<th style="width:70px"></th>
				</tr>
			</thead>
			<tbody>
				<?php
        $arr = array(
          0 => "All",
          1 => "Indonesia",
          2 => "Philippines",
          3 => "Colorado",
        );
        foreach ($catalogs as $catalog){ ?>

        <?php
          $form = $this->beginWidget('CActiveForm', array(
            'id' => 'form',
            'action' => bu('admin/catalogs/update'),
            'htmlOptions' => array(
              'class' => 'form',
              'novalidate' => 'true',
            ),
          ));
        ?>
				<tr>
					<td align="center"><a href="<?php echo bu('admin/catalogs/download'); ?>?id=<?php echo $catalog->id; ?>"><?php echo $catalog->title; ?></a></td>
					<td align="center">
            <?php echo $form->dropDownList($catalog,'catalog_category', $arr, array('required' => 'required', 'onChange' => 'submit()')); ?>
            <?php echo $form->error($catalog, 'catalog_category'); ?>
            <input type="hidden" name="id" value="<?php echo $catalog->id ?>" />
          </td>
					<td align="center"><?php echo $catalog->created_at; ?></td>
					<td>
						<ul class="action-buttons">
							<li><a href="<?php echo bu('admin/catalogs/delete'); ?>?id=<?php echo $catalog->id; ?>" method="POST" class="button button-gray no-text"><span class="bin"></span>Delete</a></li>
						</ul>
					</td>
				</tr>
        <?php $this->endWidget(); ?>
				<?php } ?>
			</tbody>
		</table>

  </section>
</div>